// src/main/expressServer.ts
import express from 'express';
import http from 'http';

let server: http.Server | null = null;

export function startExpressServer() {
  const expressApp = express();
  const port = 32068;

  expressApp.get('/', (req, res) => {
    res.send('Hello from Electron Express!');
  });

  server = expressApp.listen(port, () => {
    console.log(`Express server running at http://localhost:${port}`);
  });
}

export function stopExpressServer() {
  if (server) {
    server.close(() => {
      console.log('Express server stopped');
    });
    server = null;
  }
}